package org.example.chat.dao;

import org.example.chat.entity.Group;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface GroupRepository extends JpaRepository<Group,String> {


    @Query(value = "select cg from #{#entityName} cg where cg.id in (select ugr.id from UserGroupRelation ugr where ugr.userId = :userId)")
    List<Group> findGroupByUserId(@Param("userId") String userId);
}
